package com.paopao.loansheet.controller;

import com.paopao.domain.ItemInfoBean;
import com.paopao.domain.R;
import com.paopao.service.ItemInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/item")
public class ItemInfoComtroller {

    @Autowired
    private ItemInfoService itemInfoService;

    @PostMapping
    public R addItemInfo(@RequestBody ItemInfoBean itemInfoBean){

        return itemInfoService.addItem(itemInfoBean);
    }

    @DeleteMapping("{id:\\d+}")
    public R deleteItemInfo(@PathVariable("id")Integer id){

        return itemInfoService.deleteItem(id);
    }

    @PutMapping
    public R editItemInfo(@RequestBody ItemInfoBean itemInfoBean){

        return itemInfoService.editItem(itemInfoBean);
    }

    @GetMapping("{id:\\d+}")
    public R getItemInfo(@PathVariable("id") Integer id){

        return itemInfoService.selectItem(id);
    }

    @GetMapping
    public R getItemInfoList(@RequestParam(value = "pageNum", required = false) Integer pageNum,
                             @RequestParam(value = "pageSize", required = false, defaultValue = "25") Integer pageSize,
                             @RequestBody ItemInfoBean itemInfoBean){

        return itemInfoService.selectItemList(pageNum, pageSize, itemInfoBean);
    }

    /**
     *  给人员分配任务
     */
}
